#include "CCAttachment.h"
#include <cstdlib>
#include <cstring>
#include "CCSpineGlobal.h"



CCAttachment::CCAttachment() :
m_x(0),
m_y(0),
m_rotation(0),
m_scaleX(1),
m_scaleY(1),
m_path(NULL) {
}

CCAttachment::~CCAttachment() {
}

CCAttachment* CCAttachment::create() {
	CCAttachment* a = new CCAttachment;
	return (CCAttachment*)a->autorelease();
}

void CCAttachment::setPath(const char* path) {
    m_path=path;
}

void CCAttachment::synchro(cocos2d::Node *node) {
    node->setPosition(Point(m_x, m_y));
    node->setRotation(-m_rotation);
    node->setScaleX(m_scaleX);
    node->setScaleY(m_scaleY);
}

SpriteFrame* CCAttachment::createRelatedSpriteFrame() {
	char fileName[64];
    sprintf(fileName, "%s.png", m_path);
	return SpriteFrameCache::getInstance()->getSpriteFrameByName(fileName);
}

